package com.tianqu.tms.www.transfer.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.DateUtil;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.entity.Codes;
import com.tianqu.tms.entity.TransferAcceptedInfo;
import com.tianqu.tms.www.transfer.controller.ChangHaiInputResultController;
import com.tianqu.tms.www.transfer.viewhelper.TransferRgInputViewHelper;
/**
 * 长海县车辆录入结果页面
 * @author Administrator
 *
 */
public class ChangHaiInputResultAction extends TmsAction {
	private Logger logger = Logger.getLogger(ChangHaiInputResultAction.class);
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");	
		//check
		TransferRgInputViewHelper checkView = (TransferRgInputViewHelper)uc.getAttribute("changhaixian");
		TransferAcceptedInfo accept = new TransferAcceptedInfo();
		accept = accept.findByLicenseplate(checkView.getLicensePlate());
		if(accept!=null)
		{
			logger.debug("长海县车辆录入不通过...");	
			setErrorsToRequest(request, TmsConstants.IM016, null);
			return mapping.getInputForward();		
		}
		
		isToken(mapping, request);
		ChangHaiInputResultController controller = new ChangHaiInputResultController();
		controller.execute(uc);
		//打印
		TransferRgInputViewHelper view = (TransferRgInputViewHelper)uc.getAttribute("changhaixian");
		uc.removeAttribute("changhaixian");
		
		Codes code = Codes.getInstance();
		view.setCardTypeList(code.getCodeslistByItemId(Codes.PLATE_TYPE));// 号牌种类list
		view.setCurrentTime(DateUtil.getCurrentTimeStr3());
		
		view.setPrintBsflag("1");
		
		request.setAttribute(TmsConstants.VIEWHELP, view);
		logger.debug(this.getClass().getName() + "#execute was completed.");	
		return mapping.findForward(TmsConstants.SUCCESS);
	}
}
